package com.shiro.entity;

import java.util.Date;

import com.okok.entity.User;
import com.shiro.entity.IdEntity;
import org.springframework.data.mongodb.core.mapping.DBRef;


/**
 * 用户登录token
 * @author Eason
 *
 */
public class Token extends IdEntity {

	@DBRef
	private User user;
	
	// token
	private String token;
	
	// secret  secret 保存在客户端，用于生成密钥 key = secret + "-" + sequence
	private String secret;
	
	// 是否有效
	private Boolean valid;
	
	// 有效时间 默认7天
	private Integer validDays = 7;
	
	// 有效截止日期,根据有效时间设置截止日期.开定时或者每次登录出发验证token是否过期
	private Date validTo;

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public String getSecret() {
		return secret;
	}

	public void setSecret(String secret) {
		this.secret = secret;
	}

	public Boolean getValid() {
		return valid;
	}

	public void setValid(Boolean valid) {
		this.valid = valid;
	}

	public Date getValidTo() {
		return validTo;
	}

	public void setValidTo(Date validTo) {
		this.validTo = validTo;
	}

	public Integer getValidDays() {
		return validDays;
	}

	public void setValidDays(Integer validDays) {
		this.validDays = validDays;
	}

}